home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades reversed ƒ / Pour scroll fade reversed.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  109 lines

  1. /**********************************************************************\
  2.  
  3. File:        Pour scroll fade reversed.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short PourScrollFadeReversed(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Scroll down in tiny strips, starting at the right and moving left.  Scroll
  34.    strips 1-(N), then strips 1-(N+1), etc.  When strip 1 is done, don't do it
  35.    anymore!  (Duh, but this was difficult to get right.)  So only scroll strips
  36.    2-(N), and so on. */
  37.    
  38. pascal short PourScrollFadeReversed(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     Rect            *dest;
  41.     int                *iter;
  42.     Rect            scrollsource;
  43.     int                i;
  44.     int                startstrip,endstrip;
  45.     int                ScrollSize, BoxSize;
  46.     int                NumStrips;
  47.     
  48.     ScrollSize=theWindowHeight/50;
  49.     NumStrips=theWindowWidth/4;
  50.     BoxSize=theWindowWidth/NumStrips;
  51.     dest=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  52.     if (dest==0L)
  53.         return -1;        /* memory error */
  54.     iter=(int*)NewPtr(sizeof(int)*NumStrips);
  55.     if (iter==0L)
  56.     {
  57.         DisposePtr(dest);
  58.         return -1;        /* memory error */
  59.     }
  60.     
  61.     SetRect(&scrollsource, boundsRect.right-BoxSize, boundsRect.top,
  62.         boundsRect.right, boundsRect.bottom);
  63.         
  64.     for (i=0; i<NumStrips; i++)
  65.     {
  66.         dest[i].top = theWindowHeight-ScrollSize;
  67.         dest[i].bottom=theWindowHeight;
  68.         dest[i].left=theWindowWidth-(i+1)*BoxSize;
  69.         dest[i].right=dest[i].left+BoxSize;
  70.         OffsetRect(&(dest[i]), boundsRect.left, boundsRect.top);
  71.         
  72.         iter[i]=0;
  73.     }
  74.     
  75.     startstrip=0;
  76.     endstrip=1;
  77.     do
  78.     {
  79.         StartTiming();
  80.         
  81.         ScrollTheRect(&scrollsource, 0, -ScrollSize, 0L);
  82.         
  83.         for (i=startstrip; i<endstrip; i++)
  84.         {
  85.             FillRect(&dest[i], *thePattern);
  86.             iter[i]+=ScrollSize;
  87.         }
  88.         
  89.         if (endstrip<NumStrips)
  90.         {
  91.             endstrip++;
  92.             scrollsource.left-=BoxSize;
  93.         }
  94.         if (iter[startstrip]>=theWindowHeight)
  95.         {
  96.             startstrip++;
  97.             scrollsource.right-=BoxSize;
  98.         }
  99.         
  100.         TimeCorrection(CorrectTime);
  101.     }
  102.     while (startstrip<endstrip);
  103.     
  104.     DisposePtr(dest);
  105.     DisposePtr(iter);
  106.     
  107.     return 0;
  108. }
  109.